-
-
Notifications
You must be signed in to change notification settings - Fork 168
fix(rsc): exclude CSS imports with special queries from automatic injection #580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
CSS imports with special queries (?url, ?inline, ?raw) should not be collected for server-side rendering as they return strings rather than applying styles. This fix adds a hasSpecialCssQuery() helper function to detect and exclude these imports from the collectCss function, preventing unexpected behavior while ensuring normal CSS imports continue to work correctly. - Add hasSpecialCssQuery() helper to detect ?url, ?inline, ?raw queries - Modify collectCss() to exclude CSS imports with special queries - Add comprehensive e2e tests for both server and client components - Test all query patterns with separate CSS files to ensure proper handling Fixes #571 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes an issue where CSS imports with special queries (?url, ?inline, ?raw) were being incorrectly collected for server-side rendering, causing unexpected behavior since these queries return strings rather than applying styles.
- Add
hasSpecialCssQuery()
helper function to detect CSS imports with special queries - Modify
collectCss()
to exclude CSS imports with special queries from automatic injection - Add comprehensive e2e tests covering both server and client components with all query patterns
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
packages/plugin-rsc/src/plugin.ts | Core fix: adds helper function and excludes special CSS queries from collection |
packages/plugin-rsc/examples/basic/src/server.tsx | Updates CSP to allow inline styles for testing |
packages/plugin-rsc/examples/basic/src/routes/root.tsx | Integrates new CSS queries test component |
packages/plugin-rsc/examples/basic/src/routes/css-queries/* | Test files for CSS query functionality on both server and client |
packages/plugin-rsc/e2e/basic.test.ts | E2e test verifying CSS queries are not auto-injected but work when manually applied |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
CSS imports with special queries (?url, ?inline, ?raw) should not be collected for server-side rendering as they return strings rather than applying styles.
This fix adds a hasSpecialCssQuery() helper function to detect and exclude these imports from the collectCss function, preventing unexpected behavior while ensuring normal CSS imports continue to work correctly.
Fixes #571
🤖 Generated with Claude Code
Description